﻿using System;
using System.Runtime.InteropServices;
//using System.Threading.Tasks;

namespace LackCodePrint.Common
{
    internal class PrintLab
    { /*[DllImport("CDFPSK.dll")]
        public static extern int OpenPort(uint px);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_OpenUSBPort(uint px);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ClearBuffer();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_Connect_Timer_Buff(string IPAddredd, uint port, uint timeout);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_WriteBuffToPrinter();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_CloseBuffPort();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_CloseConnect();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetDirection(char dirction);

        [DllImport("CDFPSK.dll")]
        public static extern int ClosePort();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_CloseUSBPort();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_PrintLabel(uint number, uint cpnumber);
        [DllImport("CDFPSK.dll")]
        public static extern int SetPCComPort(System.UInt32 BaudRate, bool HandShake);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetPrintSpeed(int px);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetDarkness(uint id);

 
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_FormDel(string pid);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_FormDownload(string pid);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_FormEnd();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ExecForm(string pid);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_Download();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DownloadInitVar(string pstr);
      
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DefineCounter(uint id, uint maxNum, short ptext, string pstr, string pMsg);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawTextTrueTypeW
                                            (uint x, uint y, uint FHeight,
                                            uint FWidth, string FType,
                                            uint Fspin, uint FWeight,
                                            bool FItalic, bool FUnline,
                                            bool FStrikeOut,
                                            string id_name,
                                            string data);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawText_TrueType
                                           (uint x, uint y, uint FHeight,
                                           uint FWidth, string FType,
                                           uint Fspin, uint FWeight,
                                           bool FItalic, bool FUnline,
                                           bool FStrikeOut,
                                           string data);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawText_TrueType
                                   (uint x, uint y, uint FHeight,
                                   uint FWidth, string FType,
                                   uint Fspin, uint FWeight,
                                   bool FItalic, bool FUnline,
                                   bool FStrikeOut,
                                   byte[] data);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawBarcode(uint px,
                                        uint py,
                                        uint pdirec,
                                        string pCode,
                                        uint pHorizontal,
                                        uint pVertical,
                                        uint pbright,
                                        char ptext,
                                        string pstr);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetLabelHeight(uint lheight, uint gapH, int gapOffset, bool bFlag);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetLabelWidth(uint lwidth);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawRectangle(uint px, uint py, uint thickness, uint pEx, uint pEy);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawLineOr(uint px, uint py, uint pLength, uint pH);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawDiagonal(uint px, uint py, uint thickness, uint pEx, uint pEy);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawBar2D_QR(uint x, uint y, uint w, uint v, uint o, uint r, uint m, uint g, uint s, string pstr);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawBar2D_QREx(uint x, uint y, uint o, uint r, uint g, uint s, uint v, string id_name, string pstr);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawBar2D_Pdf417(uint x, uint y, uint w, uint v, uint s, uint c, uint px, uint py, uint r, uint l, uint t, uint o, string pstr);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_PcxGraphicsDel(string pid);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_PcxGraphicsDownload(string pcxname, string pcxpath);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawPcxGraphics(uint px, uint py, string gname);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawText(uint px, uint py, uint pdirec, uint pFont, uint pHorizontal, uint pVertical, char ptext, string pstr);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawTextEx(uint px, uint py, uint pdirec, uint pFont, uint pHorizontal, uint pVertical, char ptext, string pstr, bool varible);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawBar2D_DATAMATRIX(uint x, uint y, uint w, uint h, uint o, uint m, string pstr);
    
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawBar2D_HANXIN(uint x, uint y, uint w, uint v, uint o, uint r, uint m, uint g, uint s, string pstr);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ErrorReportUSB(uint USBport);  //160628 add by xr

        [DllImport("CDFPSK.dll")]
        public static extern int SendCmd(byte[] cmd);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SendCmd(byte[] cmd, uint len);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_RWRFIDLabel(uint nRWMode, uint nWForm, uint nStartBlock, uint nWDataNum, uint nWArea, string pstr);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadRFTagDataUSB(uint usbPort, uint nDataBlock, uint nRFPower, uint bFeed, byte[] strRFData);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadRFIDLabelData(uint nDataBlock, uint nRFPower, uint bFeed, byte[] data, uint dataSize);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadRFIDLabelDataEx(uint nDataBlock, uint nRFPower, uint bFeed, string AccessCode,byte[] data, uint dataSize);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_PrintLabelFeedback( byte[] strRFData, uint dataSize);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetReadRFIDForwardSpeed(uint speed);
        [DllImport("CDFPSK.dll")]
         public static extern int PTK_SetReadRFIDBackSpeed(uint speed);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_GetErrorInfo(int error_n, byte[] errorInfo, int infoSize);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ErrorReport_USBInterrupt(int[] status);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_FeedBack();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadData(byte[] data, uint dataSize);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetHFRFID(char pWForm, int nProtocolType, int nMaxErrNumd);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_RWHFLabel(char nRWMode, uint nStartBlock, uint nBlockNum, String pstr, Boolean Varible);


        [DllImport("CDFPSK.dll")]
        public static extern int PTK_PrintAndCallback(byte[] data, byte[] printerStatus);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadHFRFIDSetting(uint nDataBlock, uint nStartBlock, uint nRBlockLength);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadHFLabelData(uint nStartBlock, uint nBlockNum, char pFeed, byte[] data, uint dataSize);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadHFLabeUID(char pFeed, byte[] data, uint dataSize);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_AnyGraphicsPrint(uint px, uint py, string pcxname, string filePath,float ratio, uint width, uint height, uint iDire);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetPrinterState(string state);*/



        [DllImport("CDFPSK.dll")]
        public static extern int PTK_GetErrorInfo(int error_n, byte[] errorInfo, int infoSize);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_OpenLogMode(String filePath);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_CloseLogMode();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_GetLastError();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_WSAGetLastError();

        /*================================================================================
         * 编码转换
         *================================================================================*/
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_UTF8toGBK(String utf8Str, String gbkStr, int gbkStrCount);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_GBKtoUTF8(String gbkStr, String utf8Str, int utf8StrCount);

        /*================================================================================
         * 端口操作
         *================================================================================*/
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_GetAllPrinterUSBInfo(byte[] USBInfo, uint infoSize);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_OpenUSBPort(uint port);//当有且仅有一台POSTEK打印机通过USB连接到PC时，USB端口号可设置为255
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_CloseUSBPort();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_OpenSerialPort(uint port, uint bRate);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_CloseSerialPort();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_OpenPrinter(String printerName);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ClosePrinter();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_OpenParallelPort(uint port);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_CloseParallelPort();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_OpenTextPort(String fn);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_CloseTextPort();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_Connect(String IPAddr, uint netPort);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_Connect_Timer(String IPAddr, uint netPort, uint time_sec);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_CloseConnect();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_OpenUSBPort_Buff(uint portNum);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_Connect_Timer_Buff(String IPAddr, uint netPort, uint time_sec);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_OpenPrinter_Buff(String printerName);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_CloseBuffPort();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_WriteBuffToPrinter();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SendCmd(byte[] data, uint datalen);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SendString(Boolean utf8Flag, String data);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadData(byte[] data, uint dataSize);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadData(int[] data, uint dataSize);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SendFile(byte[] filePath);

        /*================================================================================
         * 打印机设置
         *================================================================================*/
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_PrintConfiguration();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_MediaDetect();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_FeedMedia();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_UserFeed(uint feedLen);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_UserBackFeed(uint feedLen);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_EnableFLASH();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DisableFLASH();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_CutPage(uint page); //存FLASH
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_CutPageEx(uint page);//不存FLASH
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetCoordinateOrigin(uint px, uint py);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_GetUtilityInfo(uint infoNum, byte[] data, uint dataSize);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetUtilityInfoProc(byte[] _G1Info, uint infoNum, String info);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetUtilityInfo(byte[] _G1Info);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_GetAllPrinterInfo(uint infoNum, Boolean fileflag, byte[] data, uint dataSize);//v7.58固件才支持
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetAllPrinterInfo(uint infoNum, String printerInfo); //v7.58固件才支持
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ErrorReport_USBInterrupt(int[] status);
        /*================================================================================
         * 标签设置
         *================================================================================*/
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ClearBuffer();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetPrintSpeed(uint speed);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetDarkness(uint dark);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetDirection(char direct);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetLabelHeight(uint lheight, uint gapH, uint gapOffset, Boolean bFlag);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetLabelWidth(uint lwidth);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_PrintLabel(uint number, uint cpnumber);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_PrintLabelFeedback(byte[] data, uint dataSize);

        /*================================================================================
         * 打印文字
         *================================================================================*/
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawText(uint px, uint py, uint pdirec, uint pFont,
            uint pHorizontal, uint pVertical, char pColor, byte[] pstr);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawTextEx(uint px, uint py, uint pdirec, uint pFont,
            uint pHorizontal, uint pVertical, char pColor, String pstr, Boolean Varible);



        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawText_TrueType(uint x, uint y, uint FHeight, uint FWidth,
    byte[] FType, uint Fspin, uint FWeight, Boolean FItalic,
    Boolean FUnline, Boolean FStrikeOut, byte[] data);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawText_TrueTypeEx(uint x, uint y, uint FHeight, uint FWidth, String FType,
            uint Fspin, uint FWeight, Boolean FItalic, Boolean FUnline, Boolean FStrikeOut,
            uint lineMaxWidth, uint lineMaxNum, int lineGapH, Boolean middleSwitch, String data);


        [DllImport("CDFPSK.dll")]
        public static extern int PTK_RenameDownloadFont(uint StoreType, char Fontname, String DownloadFontName);


        /*================================================================================
         * 打印图片
         *================================================================================*/
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_BinGraphicsList();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_BinGraphicsDel(String binname);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_BinGraphicsDownload(String binname, uint pbyte, uint pH, byte[] Gdata);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_RecallBinGraphics(uint px, uint py, String binname);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawBinGraphics(uint px, uint py, uint pbyte, uint pH, byte[] Gdata);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ChangeIMGtoPCX(String filePath);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_PcxGraphicsList();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_PcxGraphicsDel(String pcxname);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_AnyGraphicsDownload(String pcxname, String filePath, float ratio,
                uint width, uint height, uint iDire);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawPcxGraphics(uint px, uint py, byte[] pcxname);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_AnyGraphicsPrint(uint px, uint py, String pcxname, String filePath,
            float ratio, uint width, uint height, uint iDire);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_AnyGraphicsDownloadFromMemory(String pcxname, uint imageType, uint imageSize,
             float ratio, uint width, uint height, uint iDire, byte[] imageBuffer);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_AnyGraphicsPrintFromMemory(int px, int py, String pcxname, uint imageType, uint imageSize,
            float ratio, uint width, uint height, uint iDire, byte[] imageBuffer);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_AnyGraphicsPrint_Base64(uint px, uint py, uint imageType,
            float ratio, uint width, uint height, uint iDire, String imageBuffer);

        /*================================================================================
         * 打印线条
         *================================================================================*/
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawRectangle(uint px, uint py, uint thickness, uint pEx, uint pEy);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawLineXor(uint px, uint py, uint pL, uint pH);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawLineOr(uint px, uint py, uint pL, uint pH);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawDiagonal(uint px, uint py, uint thickness, uint pEx, uint pEy);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawWhiteLine(uint px, uint py, uint pL, uint pH);


        /*================================================================================
         * 打印二维条码（b指令）
         *================================================================================*/
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawBar2D_QR(uint x, uint y,
            uint w, uint v, uint o, uint r, uint m, uint g, uint s, byte[] pstr);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawBar2D_QREx(uint x, uint y,
            uint o, uint r, uint g, uint v, uint s, String binname, byte[] pstr);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawBar2D_HANXIN(uint x, uint y,
           uint w, uint v, uint o, uint r, uint m, uint g, uint s, byte[] pstr);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawBar2D_Pdf417(uint x, uint y,
            uint w, uint v, uint s, uint c, uint px, uint py, uint r, uint l, uint t, uint o, byte[] pstr);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawBar2D_Pdf417Ex(uint x, uint y,
            uint w, uint v, uint s, uint c, uint px, uint py, uint r, uint l, uint t, uint o, byte[] pstr);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawBar2D_MaxiCode(uint x, uint y,
         uint m, uint u, String pstr);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawBar2D_DATAMATRIX(uint x, uint y,
        uint w, uint v, uint o, uint m, byte[] pstr);

        /*================================================================================
         * 打印条码方法（B指令）
         *================================================================================*/
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawBarcode(uint px, uint py,
             uint pdirec, String pCode,
             uint NarrowWidth,
             uint pHorizontal,
             uint pVertical,
             char ptext, byte[] pstr);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawBarcodeEx(uint px, uint py,
           uint pdirec, String pCode,
           uint NarrowWidth,
           uint pHorizontal,
           uint pVertical,
           char ptext, String pstr, Boolean Varible);


        /*================================================================================
         *  打印表单及相关
         *================================================================================*/
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_GetStorageList(byte[] listBuff, uint listBuffSize, int TempType);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_FormList();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_FormDel(String pid);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_FormDownload(String pid);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_FormEnd();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ExecForm(String pid);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DefineVariable(uint id, uint maxNum, char ptext, String hintMsg);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DefineCounter(uint id, uint maxNum, char ptext, String prule, String hintMsg);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_Download();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DownloadInitVar(String pstr);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_PrintLabelAuto(uint number, uint cpnumber);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_FormPrinting(String FormName, String FormVariable, uint Quantity, uint Copies);

        /*================================================================================
         *  RFID超高频打印接口
         *================================================================================*/
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_RFIDCalibrate();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_RWRFIDLabel(uint nRWMode, uint nWForm, uint nStartBlock, uint nWDataNum, uint nWArea, String pstr);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetRFLabelPWAndLockRFLabel(uint nOperationMode, uint OperationnArea, String pstr);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetRFID(uint nReservationParameters, uint nReadWriteLocation, uint ReadWriteArea, uint nMaxErrNum, uint nErrProcessingMethod);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadRFIDLabelData(uint nDataBlock, uint nRFPower, uint bFeed, byte[] data, uint dataSize);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadRFIDLabelDataEx(uint nDataBlock, uint nRFPower, uint bFeed, String AccessCode, byte[] data, uint dataSize);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_RFIDEndPrintLabel(uint block, byte[] data, uint dataSize);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_RFIDEndPrintLabelFeedBack(uint block, byte[] data, uint dataSize, byte[] printerStatus, uint statusSize);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetReadRFIDForwardSpeed(uint speed);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetReadRFIDBackSpeed(uint speed);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_EncodeRFIDPC(String PCValue);
        //RF指令不被N指令清空
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_RWRFIDLabelEx(uint nRWMode, uint nWForm, uint nStartBlock, uint nWDataNum, uint nWArea, String pstr);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadRFIDSetting(uint nRMode, uint nStartBlock, uint nRBlockLength, String AccessCode);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_PrintAndCallback(byte[] data, byte[] printerStatus);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_PrintAndReturnStatus(byte[] printerStatus);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_GetPrinterStatus(String checkCode, byte[] printerStatus);

        /*================================================================================
         *  HF高频打印接口
         *================================================================================*/
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_RWHFLabel(char nRWMode, uint nStartBlock, uint nBlockNum, String pstr, Boolean Varible);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetHFRFID(char pWForm, uint nProtocolType, uint nMaxErrNumd);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadHFLabelData(uint nStartBlock, uint nBlockNum, char pFeed, byte[] data, uint dataSize);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadHFLabeUID(char pFeed, byte[] data, uint dataSize);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadHFTagDataPrintAuto(uint nStartBlock, uint nBlockNum);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadHFTagUIDPrintAuto();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetHFAFI(int nAFIValue);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetHFDSFID(int nDSFIDValue);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetHFEAS(char EAS);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_HFDecrypt(int key, String password);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_HFDecrypt(int key, uint nStartBlock, uint nBlockNum, String VerifyPassword);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_LockHFLabel(int nStartBlock, int nBlockNum, String keyA, String keyB);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_LockHFLabel(int nStartBlock, int nBlockNum, String keyA, String keyB, String nControlByte);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_LockHFLabel(char pLockIdentifier, int BlockAddr);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_LockHFIdentifier(char Identifier);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_LockHFBlock(uint nStartBlock, uint nBlockNum);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadHFRFIDSetting(uint nDataBlock, uint nStartBlock, uint nRBlockLength);


        /*以下为老版本兼容接口，部分不建议使用*/
        [DllImport("CDFPSK.dll")]
        public static extern int OpenPort(uint port);
        [DllImport("CDFPSK.dll")]
        public static extern int ClosePort();
        [DllImport("CDFPSK.dll")]
        public static extern int SetPCComPort(uint BaudRate, Boolean HandShake);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_Reset();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DrawTextTrueTypeW(uint x, uint y,
            uint FHeight, uint FWidth,
            String FType, uint Fspin,
            uint FWeight, Boolean FItalic,
            Boolean FUnline, Boolean FStrikeOut,
            String id_name, String data);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_PcxGraphicsDownload(String pcxname, String pcxpath);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_PrintPCX(uint px, uint py, String filePath);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SoftFontList();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SoftFontDel(char pid);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetFontGap(int gap);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetCharSets(uint BitValue, char CharSets, String CountryCode);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_GetUSBID(byte[] USBDeviceSerial);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DisableBackFeed();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_EnableBackFeed();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetPrinterState(char state);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_DisableErrorReport();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_EnableErrorReport();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_FeedBack();
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ErrorReport(uint wPort, uint rPort, uint BaudRate, Boolean HandShake, uint TimeOut);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ErrorReportNet(String PrintIPAddress, uint PrinterNetPort);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ErrorReportUSB(uint USBport);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadStatusDataUSB(uint usbPort, byte[] strRFData);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadPrintConifUSB(uint usbPort, uint nInfoType, byte[] strData);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadPrintConifNet(String PrintIPAddress, uint PrinterNetPort, uint nInfoType, byte[] strData);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadRFTagData(uint wPort, uint rPort, uint BaudRate,
            Boolean HandShake, uint TimeOut, uint nDataBlock,
            uint nRFPower, Boolean bFeed, byte[] strRFData);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadRFTagDataUSB(uint usbPort, uint nDataBlock,
            uint nRFPower, Boolean bFeed, byte[] strRFData);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadRFTagDataNet(String IPAddress, uint Port, uint nDataBlock,
            uint nRFPower, Boolean bFeed, byte[] strRFData);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadHFTagDataUSB(uint usbPort, uint nStartBlock,
            uint nBlockNum, char pFeed, byte[] strRFData);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadHFTagDataNet(String IPAddress, uint Port, uint nStartBlock,
            uint nBlockNum, char pFeed, byte[] strRFData);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadHFTagUID(uint wPort, uint rPort, uint BaudRate,
            Boolean HandShake, uint TimeOut, char pFeed, byte[] strRFData);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadHFTagUIDUSB(uint usbPort, char pFeed, byte[] strRFData);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadHFTagUIDNet(String IPAddress, uint Port, char pFeed, byte[] strRFData);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_GetPrinterDPI(int[] dpi);
        [DllImport("CDFPSK.dll")]
        public static extern int PTK_SetTearAndTphOffset(float tear_offset, float tph_offset);

        [DllImport("CDFPSK.dll")]
        public static extern int PTK_ReadSerialNumberNet(String PrintIPAddress, uint PrinterNetPort, byte[] strData);


    }
}
